package action.article;

import java.util.Map;

import org.apache.struts2.ServletActionContext;

import service.ArticleService;
import bean.Article;
import bean.User;

import com.opensymphony.xwork2.ActionSupport;

public class SaveArticleAction extends ActionSupport {
	private Article article;
	private ArticleService articleService;
	
	@Override
	public String execute() throws Exception {
		Map session=ServletActionContext.getContext().getSession();
		User u=(User) session.get("user");
		article.setUser(u);
		if(articleService.addArticle(article))
			return SUCCESS;
		return INPUT;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public ArticleService getArticleService() {
		return articleService;
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}
	
	
}
